<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>Net::Telnet - interact with TELNET port or other TCP ports - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of Net-Telnet - MetaCPAN" href="https://metacpan.org/dist/Net-Telnet/releases.rss" />
        <link rel="canonical" href="./Net::Telnet.html" />
        <meta name="description" content="interact with TELNET port or other TCP ports" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/Net::Telnet" />
<meta name="twitter:title"       content="Net::Telnet" />
<meta name="twitter:description" content="interact with TELNET port or other TCP ports" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./Net::Telnet.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of Net-Telnet was released.">
      <span class="relatize">21 Jun 2021 03:47:48 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/Net-Telnet">Net-Telnet</a>
  </li>
  <li>
    Module version: 3.05
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/Net-Telnet/source/lib/Net/Telnet.pm">Source</a>
    (<a href="https://metacpan.org/dist/Net-Telnet/source/lib/Net/Telnet.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/Net-Telnet/source/lib/Net">Browse</a>
    (<a href="https://metacpan.org/dist/Net-Telnet/source/lib/Net?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/Net-Telnet/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/Net-Telnet/contribute">How to Contribute</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://rt.cpan.org/Public/Dist/Display.html?Name=Net-Telnet">Issues</a>
      (2)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=Net-Telnet+3.05" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/N/Net-Telnet.html?oncpan=1&amp;distmat=1&amp;version=3.05&amp;grade=2" style="color: #090">2160</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/N/Net-Telnet.html?oncpan=1&amp;distmat=1&amp;version=3.05&amp;grade=3" style="color: #900">0</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/N/Net-Telnet.html?oncpan=1&amp;distmat=1&amp;version=3.05&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/JROGERS/Net-Telnet-3.05">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on Net-Telnet who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 0
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/Net-Telnet-3.05/index.html">% Coverage </a>
    </li>
    <li>
      License: perl_5
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/Net-Telnet/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/J/JR/JROGERS/Net-Telnet-3.05.tar.gz">
      Download (<span itemprop="fileSize">41.56KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FJROGERS%2FNet-Telnet-3.05%2Flib%2FNet%2FTelnet.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Net-Telnet/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Net-Telnet/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:Net-Telnet">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="Net-Telnet">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Net/Telnet.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="JROGERS/Net-Telnet-3.05"
>3.05
  (JROGERS on 2021-06-21)</option>
<option
  
  value="DLAMBLEY/Net-Telnet-3.04_01"
>3.04_01 DEV
  (DLAMBLEY on 2020-02-17)</option>
<option
  
  value="JROGERS/Net-Telnet-3.04"
>3.04
  (JROGERS on 2013-04-21)</option>
<option
  
  value="JROGERS/Net-Telnet-3.03"
>3.03
  (JROGERS on 2002-07-17)</option>
<option
  
  value="JROGERS/Net-Telnet-3.02"
>3.02
  (JROGERS on 2000-05-27)</option>
<option
  
  value="JROGERS/Net-Telnet-3.01"
>3.01
  (JROGERS on 1997-12-30)</option>
<optgroup label="BackPAN">'
<option
  
  value="JROGERS/Net-Telnet-3.00"
>3.00
  (JROGERS on 1997-03-18)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/JROGERS/Net-Telnet-3.05/diff/' + encodeURIComponent(this.value) + '/lib/Net/Telnet.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="JROGERS/Net-Telnet-3.05"
>3.05
  (JROGERS on 2021-06-21)</option>
<option
  
  value="DLAMBLEY/Net-Telnet-3.04_01"
>3.04_01 DEV
  (DLAMBLEY on 2020-02-17)</option>
<option
  
  value="JROGERS/Net-Telnet-3.04"
>3.04
  (JROGERS on 2013-04-21)</option>
<option
  
  value="JROGERS/Net-Telnet-3.03"
>3.03
  (JROGERS on 2002-07-17)</option>
<option
  
  value="JROGERS/Net-Telnet-3.02"
>3.02
  (JROGERS on 2000-05-27)</option>
<option
  
  value="JROGERS/Net-Telnet-3.01"
>3.01
  (JROGERS on 1997-12-30)</option>
<optgroup label="BackPAN">'
<option
  
  value="JROGERS/Net-Telnet-3.00"
>3.00
  (JROGERS on 1997-03-18)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><i class="ttip" title="dynamic_config enabled">unknown</i></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/Net::Telnet/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=Net%3A%3ATelnet">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=Net-Telnet">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/JROGERS/Net-Telnet-3.05/view/lib/Net/Telnet.pm">This version</a>
    </li>
    <li>
      <a href="./Net::Telnet.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
<a class="display-all" href="https://metacpan.org/author/KARJALA"><img src="https://www.gravatar.com/avatar/9685932c4be47d9e6370f49230700c40?d=identicon&amp;s=20" title="KARJALA" alt="KARJALA"></a>
<a class="display-all" href="https://metacpan.org/author/RWP"><img src="https://www.gravatar.com/avatar/7110eb2389e69a066d9d7cad7a1cc2bf?d=identicon&amp;s=20" title="RWP" alt="RWP"></a>
</div>
<!-- Display counts of plussers-->
<div>
    <a href="https://metacpan.org/dist/Net-Telnet/plussers">2 PAUSE users</a>
</div>
<div>
    1 non-PAUSE user
</div>
</div>
    </li>
    <li>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/JROGERS" class="author-name">Jay Rogers</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Net/Telnet.pm&#39;" class="">
<option
  selected
  value="JROGERS/Net-Telnet-3.05"
>3.05
  (JROGERS on 2021-06-21)</option>
<option
  
  value="DLAMBLEY/Net-Telnet-3.04_01"
>3.04_01 DEV
  (DLAMBLEY on 2020-02-17)</option>
<option
  
  value="JROGERS/Net-Telnet-3.04"
>3.04
  (JROGERS on 2013-04-21)</option>
<option
  
  value="JROGERS/Net-Telnet-3.03"
>3.03
  (JROGERS on 2002-07-17)</option>
<option
  
  value="JROGERS/Net-Telnet-3.02"
>3.02
  (JROGERS on 2000-05-27)</option>
<option
  
  value="JROGERS/Net-Telnet-3.01"
>3.01
  (JROGERS on 1997-12-30)</option>
<optgroup label="BackPAN">'
<option
  
  value="JROGERS/Net-Telnet-3.00"
>3.00
  (JROGERS on 1997-03-18)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/Net-Telnet">Net-Telnet-3.05</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage two &#10;
          • 32 direct dependents &#10;          • 42 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="15"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="Net-Telnet-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="Net-Telnet-3.05">
    <input type="hidden" name="author" value="JROGERS">
    <input type="hidden" name="distribution" value="Net-Telnet">
    <button type="submit" class="favorite highlight"><span>3</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./Net::Telnet.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>3</span> ++</a>
</div>
   / <span>Net::Telnet</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./Net::Telnet.html#NAME">NAME</a></li>
  <li><a href="./Net::Telnet.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./Net::Telnet.html#DESCRIPTION">DESCRIPTION</a>
    <ul>
      <li><a href="./Net::Telnet.html#What-To-Know-Before-Using">What To Know Before Using</a></li>
      <li><a href="./Net::Telnet.html#Debugging">Debugging</a></li>
      <li><a href="./Net::Telnet.html#Style-of-Named-Parameters">Style of Named Parameters</a></li>
      <li><a href="./Net::Telnet.html#Connecting-to-a-Remote-MS-Windows-Machine">Connecting to a Remote MS-Windows Machine</a></li>
    </ul>
  </li>
  <li><a href="./Net::Telnet.html#METHODS">METHODS</a></li>
  <li><a href="./Net::Telnet.html#SEE-ALSO">SEE ALSO</a></li>
  <li><a href="./Net::Telnet.html#EXAMPLES">EXAMPLES</a></li>
  <li><a href="./Net::Telnet.html#AUTHOR">AUTHOR</a></li>
  <li><a href="./Net::Telnet.html#CREDITS">CREDITS</a></li>
  <li><a href="./Net::Telnet.html#COPYRIGHT">COPYRIGHT</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>Net::Telnet - interact with TELNET port or other TCP ports</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<p><code>use Net::Telnet ();</code></p>

<p>see METHODS or EXAMPLES sections below</p>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>Net::Telnet allows you to make client connections to a TCP port and do network I/O, especially to a port using the TELNET protocol. Simple I/O methods such as print, get, and getline are provided. More sophisticated interactive features are provided because connecting to a TELNET port ultimately means communicating with a program designed for human interaction. These interactive features include the ability to specify a time-out and to wait for patterns to appear in the input stream, such as the prompt from a shell. IPv6 support is available when using perl 5.14 or later, see <code>family()</code>.</p>

<p>Other reasons to use this module than strictly with a TELNET port are:</p>

<ul>

<li><p>You&#39;re not familiar with sockets and you want a simple way to make client connections to TCP services.</p>

</li>
<li><p>You want to be able to specify your own time-out while connecting, reading, or writing.</p>

</li>
<li><p>You&#39;re communicating with an interactive program at the other end of some socket or pipe and you want to wait for certain patterns to appear.</p>

</li>
</ul>

<p>Here&#39;s an example that prints who&#39;s logged-on to a remote host. In addition to a username and password, you must also know the user&#39;s shell prompt, which for this example is <code>&quot;bash$ &quot;</code></p>

<pre><code>    use Net::Telnet ();
    $t = new Net::Telnet (Timeout =&gt; 10,
                          Prompt =&gt; &#39;/bash\$ $/&#39;);
    $t-&gt;open($host);
    $t-&gt;login($username, $passwd);
    @lines = $t-&gt;cmd(&quot;who&quot;);
    print @lines;</code></pre>

<p>See the <b>EXAMPLES</b> section below for more examples.</p>

<p>Usage questions should be directed to the perlmonks.org discussion group. Bugs can be viewed or reported at cpan.org on the Net::Telnet page.</p>

<h2 id="What-To-Know-Before-Using"><a id="What"></a>What To Know Before Using</h2>

<ul>

<li><p>All output is flushed while all input is buffered. Each object contains its own input buffer.</p>

</li>
<li><p>The output record separator for <code>print()</code> and <code>cmd()</code> is set to <code>&quot;\n&quot;</code> by default, so that you don&#39;t have to append all your commands with a newline. To avoid printing a trailing <code>&quot;\n&quot;</code> use <code>put()</code> or set the <i>output_record_separator</i> to <code>&quot;&quot;</code>.</p>

</li>
<li><p>The methods <code>login()</code> and <code>cmd()</code> use the <i>prompt</i> setting in the object to determine when a login or remote command is complete. Those methods will fail with a time-out if you don&#39;t set the prompt correctly.</p>

</li>
<li><p>Use a combination of <code>print()</code> and <code>waitfor()</code> as an alternative to <code>login()</code> or <code>cmd()</code> when they don&#39;t do what you want.</p>

</li>
<li><p>Errors such as timing-out are handled according to the error mode action. The default action is to print an error message to standard error and have the program die. See the <code>errmode()</code> method for more information.</p>

</li>
<li><p>When constructing the match operator argument for <code>prompt()</code> or <code>waitfor()</code>, always use single quotes instead of double quotes to avoid unexpected backslash interpretation (e.g. <code>&#39;/bash\$ $/&#39;</code>). If you&#39;re constructing a DOS like file path, you&#39;ll need to use four backslashes to represent one (e.g. <code>&#39;/c:\\\\users\\\\bill&gt;$/i&#39;</code>).</p>

<p>Of course don&#39;t forget about regexp metacharacters like <code>.</code>, <code>[</code>, or <code>$</code>. You&#39;ll only need a single backslash to quote them. The anchor metacharacters <code>^</code> and <code>$</code> refer to positions in the input buffer. To avoid matching characters read that look like a prompt, it&#39;s a good idea to end your prompt pattern with the <code>$</code> anchor. That way the prompt will only match if it&#39;s the last thing read.</p>

</li>
<li><p>In the input stream, each sequence of <i>carriage return</i> and <i>line feed</i> (i.e. <code>&quot;\015\012&quot;</code> or CR LF) is converted to <code>&quot;\n&quot;</code>. In the output stream, each occurrence of <code>&quot;\n&quot;</code> is converted to a sequence of CR LF. See <code>binmode()</code> to change the behavior. TCP protocols typically use the ASCII sequence, carriage return and line feed to designate a newline.</p>

</li>
<li><p>Timing-out while making a connection is disabled for machines that don&#39;t support the <code>alarm()</code> function. Most notably these include MS-Windows machines.</p>

</li>
<li><p>You&#39;ll need to be running at least Perl version 5.002 to use this module. This module does not require any libraries that don&#39;t already come with a standard Perl distribution.</p>

<p>If you have the IO:: libraries installed (they come standard with perl5.004 and later) then IO::Socket::INET is used as a base class, otherwise FileHandle is used.</p>

</li>
</ul>

<h2 id="Debugging">Debugging</h2>

<p>The typical usage bug causes a time-out error because you&#39;ve made incorrect assumptions about what the remote side actually sends. The easiest way to reconcile what the remote side sends with your expectations is to use <code>input_log()</code> or <code>dump_log()</code>.</p>

<p><code>dump_log()</code> allows you to see the data being sent from the remote side before any translation is done, while <code>input_log()</code> shows you the results after translation. The translation includes converting end of line characters, removing and responding to TELNET protocol commands in the data stream.</p>

<h2 id="Style-of-Named-Parameters"><a id="Style"></a>Style of Named Parameters</h2>

<p>Two different styles of named parameters are supported. This document only shows the IO:: style:</p>

<pre><code>    Net::Telnet-&gt;new(Timeout =&gt; 20);</code></pre>

<p>however the dash-option style is also allowed:</p>

<pre><code>    Net::Telnet-&gt;new(-timeout =&gt; 20);</code></pre>

<h2 id="Connecting-to-a-Remote-MS-Windows-Machine"><a id="Connecting"></a>Connecting to a Remote MS-Windows Machine</h2>

<p>By default MS-Windows doesn&#39;t come with a TELNET server. However third party TELNET servers are available. Unfortunately many of these servers falsely claim to be a TELNET server. This is especially true of the so-called &quot;Microsoft Telnet Server&quot; that comes installed with some newer versions MS-Windows.</p>

<p>When a TELNET server first accepts a connection, it must use the ASCII control characters carriage-return and line-feed to start a new line (see RFC854). A server like the &quot;Microsoft Telnet Server&quot; that doesn&#39;t do this, isn&#39;t a TELNET server. These servers send ANSI terminal escape sequences to position to a column on a subsequent line and to even position while writing characters that are adjacent to each other. Worse, when sending output these servers resend previously sent command output in a misguided attempt to display an entire terminal screen.</p>

<p>Connecting Net::Telnet to one of these false TELNET servers makes your job of parsing command output very difficult. It&#39;s better to replace a false TELNET server with a real TELNET server. The better TELNET servers for MS-Windows allow you to avoid the ANSI escapes by turning off something some of them call <i>console mode</i>.</p>

<h1 id="METHODS">METHODS</h1>

<p>In the calling sequences below, square brackets <b>[]</b> represent optional parameters.</p>

<dl>

<dt id="new-create-a-new-Net::Telnet-object"><a id="new"></a><b>new</b> - create a new Net::Telnet object</dt>
<dd>

<pre><code>    $obj = new Net::Telnet ([$host]);

    $obj = new Net::Telnet ([Binmode    =&gt; $mode,]
                            [Cmd_remove_mode =&gt; $mode,]
                            [Dump_Log   =&gt; $filename,]
                            [Errmode    =&gt; $errmode,]
                            [Family     =&gt; $family,]
                            [Fhopen     =&gt; $filehandle,]
                            [Host       =&gt; $host,]
                            [Input_log  =&gt; $file,]
                            [Input_record_separator =&gt; $chars,]
                            [Localfamily =&gt; $family,]
                            [Localhost   =&gt; $host,]
                            [Max_buffer_length =&gt; $len,]
                            [Ofs        =&gt; $chars,]
                            [Option_log =&gt; $file,]
                            [Ors        =&gt; $chars,]
                            [Output_field_separator =&gt; $chars,]
                            [Output_log =&gt; $file,]
                            [Output_record_separator =&gt; $chars,]
                            [Port       =&gt; $port,]
                            [Prompt     =&gt; $matchop,]
                            [Rs         =&gt; $chars,]
                            [Telnetmode =&gt; $mode,]
                            [Timeout    =&gt; $secs,]);</code></pre>

<p>This is the constructor for Net::Telnet objects. A new object is returned on success, the error mode action is performed on failure - see <code>errmode()</code>. The optional arguments are short-cuts to methods of the same name.</p>

<p>If the <i>$host</i> argument is given then the object is opened by connecting to TCP <i>$port</i> on <i>$host</i>. Also see <code>open()</code>. The new object returned is given the following defaults in the absence of corresponding named parameters:</p>

<ul>

<li><p>The default <i>Host</i> is <code>&quot;localhost&quot;</code></p>

</li>
<li><p>The default <i>Port</i> is <code>23</code></p>

</li>
<li><p>The default <i>Family</i> is <code>&quot;ipv4&quot;</code></p>

</li>
<li><p>The default <i>Prompt</i> is <code>&#39;/[\$%#&gt;] $/&#39;</code></p>

</li>
<li><p>The default <i>Timeout</i> is <code>10</code></p>

</li>
<li><p>The default <i>Errmode</i> is <code>&quot;die&quot;</code></p>

</li>
<li><p>The default <i>Output_record_separator</i> is <code>&quot;\n&quot;</code>. Note that <i>Ors</i> is synonymous with <i>Output_record_separator</i>.</p>

</li>
<li><p>The default <i>Input_record_separator</i> is <code>&quot;\n&quot;</code>. Note that <i>Rs</i> is synonymous with <i>Input_record_separator</i>.</p>

</li>
<li><p>The default <i>Binmode</i> is <code>0</code>, which means do newline translation.</p>

</li>
<li><p>The default <i>Telnetmode</i> is <code>1</code>, which means respond to TELNET commands in the data stream.</p>

</li>
<li><p>The default <i>Cmd_remove_mode</i> is <code>&quot;auto&quot;</code></p>

</li>
<li><p>The defaults for <i>Dump_log</i>, <i>Input_log</i>, <i>Option_log</i>, and <i>Output_log</i> are <code>&quot;&quot;</code>, which means that logging is turned-off.</p>

</li>
<li><p>The default <i>Max_buffer_length</i> is <code>1048576</code> bytes, i.e. 1 MiB.</p>

</li>
<li><p>The default <i>Output_field_separator</i> is <code>&quot;&quot;</code>. Note that <i>Ofs</i> is synonymous with <i>Output_field_separator</i>.</p>

</li>
<li><p>The default <i>Localhost</i> is <code>&quot;&quot;</code></p>

</li>
<li><p>The default <i>Localfamily</i> is <code>&quot;ipv4&quot;</code></p>

</li>
</ul>

</dd>
</dl>

<dl>

<dt id="binmode-toggle-newline-translation"><a id="binmode"></a><b>binmode</b> - toggle newline translation</dt>
<dd>

<pre><code>    $mode = $obj-&gt;binmode;

    $prev = $obj-&gt;binmode($mode);</code></pre>

<p>This method controls whether or not sequences of carriage returns and line feeds (CR LF or more specifically <code>&quot;\015\012&quot;</code>) are translated. By default they are translated (i.e. binmode is <code>0</code>).</p>

<p>If no argument is given, the current mode is returned.</p>

<p>If <i>$mode</i> is <code>1</code> then binmode is <i>on</i> and newline translation is not done.</p>

<p>If <i>$mode</i> is <code>0</code> then binmode is <i>off</i> and newline translation is done. In the input stream, each sequence of CR LF is converted to <code>&quot;\n&quot;</code> and in the output stream, each occurrence of <code>&quot;\n&quot;</code> is converted to a sequence of CR LF.</p>

<p>Note that input is always buffered. Changing binmode doesn&#39;t effect what&#39;s already been read into the buffer. Output is not buffered and changing binmode will have an immediate effect.</p>

</dd>
</dl>

<dl>

<dt id="break-send-TELNET-break-character"><a id="break"></a><b>break</b> - send TELNET break character</dt>
<dd>

<pre><code>    $ok = $obj-&gt;break;</code></pre>

<p>This method sends the TELNET break character. This character is provided because it&#39;s a signal outside the ASCII character set which is currently given local meaning within many systems. It&#39;s intended to indicate that the Break Key or the Attention Key was hit.</p>

<p>This method returns <code>1</code> on success, or performs the error mode action on failure.</p>

</dd>
</dl>

<dl>

<dt id="buffer-scalar-reference-to-object&#39;s-input-buffer"><a id="buffer"></a><a id="buffer-scalar-reference-to-object-s-input-buffer"></a><b>buffer</b> - scalar reference to object&#39;s input buffer</dt>
<dd>

<pre><code>    $ref = $obj-&gt;buffer;</code></pre>

<p>This method returns a scalar reference to the input buffer for <i>$obj</i>. Data in the input buffer is data that has been read from the remote side but has yet to be read by the user. Modifications to the input buffer are returned by a subsequent read.</p>

</dd>
</dl>

<dl>

<dt id="buffer_empty-discard-all-data-in-object&#39;s-input-buffer"><a id="buffer_empty"></a><a id="buffer_empty-discard-all-data-in-object-s-input-buffer"></a><b>buffer_empty</b> - discard all data in object&#39;s input buffer</dt>
<dd>

<pre><code>    $obj-&gt;buffer_empty;</code></pre>

<p>This method removes all data in the input buffer for <i>$obj</i>.</p>

</dd>
</dl>

<dl>

<dt id="close-close-object"><a id="close"></a><b>close</b> - close object</dt>
<dd>

<pre><code>    $ok = $obj-&gt;close;</code></pre>

<p>This method closes the socket, file, or pipe associated with the object. It always returns a value of <code>1</code>.</p>

</dd>
</dl>

<dl>

<dt id="cmd-issue-command-and-retrieve-output"><a id="cmd"></a><b>cmd</b> - issue command and retrieve output</dt>
<dd>

<pre><code>    $ok = $obj-&gt;cmd($string);
    $ok = $obj-&gt;cmd(String   =&gt; $string,
                    [Output  =&gt; $ref,]
                    [Cmd_remove_mode =&gt; $mode,]
                    [Errmode =&gt; $mode,]
                    [Input_record_separator =&gt; $chars,]
                    [Ors     =&gt; $chars,]
                    [Output_record_separator =&gt; $chars,]
                    [Prompt  =&gt; $match,]
                    [Rs      =&gt; $chars,]
                    [Timeout =&gt; $secs,]);

    @output = $obj-&gt;cmd($string);
    @output = $obj-&gt;cmd(String   =&gt; $string,
                        [Output  =&gt; $ref,]
                        [Cmd_remove_mode =&gt; $mode,]
                        [Errmode =&gt; $mode,]
                        [Input_record_separator =&gt; $chars,]
                        [Ors     =&gt; $chars,]
                        [Output_record_separator =&gt; $chars,]
                        [Prompt  =&gt; $match,]
                        [Rs      =&gt; $chars,]
                        [Timeout =&gt; $secs,]);</code></pre>

<p>This method sends the command <i>$string</i>, and reads the characters sent back by the command up until and including the matching prompt. It&#39;s assumed that the program to which you&#39;re sending is some kind of command prompting interpreter such as a shell.</p>

<p>The command <i>$string</i> is automatically appended with the output_record_separator, by default it is <code>&quot;\n&quot;</code>. This is similar to someone typing a command and hitting the return key. Set the output_record_separator to change this behavior.</p>

<p>In a scalar context, the characters read from the remote side are discarded and <code>1</code> is returned on success. On time-out, eof, or other failures, the error mode action is performed. See <code>errmode()</code>.</p>

<p>In a list context, just the output generated by the command is returned, one line per element. In other words, all the characters in between the echoed back command string and the prompt are returned. If the command happens to return no output, a list containing one element, the empty string is returned. This is so the list will indicate true in a boolean context. On time-out, eof, or other failures, the error mode action is performed. See <code>errmode()</code>.</p>

<p>The characters that matched the prompt may be retrieved using <code>last_prompt()</code>.</p>

<p>Many command interpreters echo back the command sent. In most situations, this method removes the first line returned from the remote side (i.e. the echoed back command). See <code>cmd_remove_mode()</code> for more control over this feature.</p>

<p>Use <code>dump_log()</code> to debug when this method keeps timing-out and you don&#39;t think it should.</p>

<p>Consider using a combination of <code>print()</code> and <code>waitfor()</code> as an alternative to this method when it doesn&#39;t do what you want, e.g. the command you send prompts for input.</p>

<p>The <i>Output</i> named parameter provides an alternative method of receiving command output. If you pass a scalar reference, all the output (even if it contains multiple lines) is returned in the referenced scalar. If you pass an array or hash reference, the lines of output are returned in the referenced array or hash. You can use <code>input_record_separator()</code> to change the notion of what separates a line.</p>

<p>Optional named parameters are provided to override the current settings of cmd_remove_mode, errmode, input_record_separator, ors, output_record_separator, prompt, rs, and timeout. Rs is synonymous with input_record_separator and ors is synonymous with output_record_separator.</p>

</dd>
</dl>

<dl>

<dt id="cmd_remove_mode-toggle-removal-of-echoed-commands"><a id="cmd_remove_mode"></a><b>cmd_remove_mode</b> - toggle removal of echoed commands</dt>
<dd>

<pre><code>    $mode = $obj-&gt;cmd_remove_mode;

    $prev = $obj-&gt;cmd_remove_mode($mode);</code></pre>

<p>This method controls how to deal with echoed back commands in the output returned by cmd(). Typically, when you send a command to the remote side, the first line of output returned is the command echoed back. Use this mode to remove the first line of output normally returned by cmd().</p>

<p>If no argument is given, the current mode is returned.</p>

<p>If <i>$mode</i> is <code>0</code> then the command output returned from cmd() has no lines removed. If <i>$mode</i> is a positive integer, then the first <i>$mode</i> lines of command output are stripped.</p>

<p>By default, <i>$mode</i> is set to <code>&quot;auto&quot;</code>. Auto means that whether or not the first line of command output is stripped, depends on whether or not the remote side offered to echo. By default, Net::Telnet always accepts an offer to echo by the remote side. You can change the default to reject such an offer using <code>option_accept()</code>.</p>

<p>A warning is printed to STDERR when attempting to set this attribute to something that is not <code>&quot;auto&quot;</code> or a non-negative integer.</p>

</dd>
</dl>

<dl>

<dt id="dump_log-log-all-I/O-in-dump-format"><a id="dump_log"></a><a id="dump_log-log-all-I-O-in-dump-format"></a><b>dump_log</b> - log all I/O in dump format</dt>
<dd>

<pre><code>    $fh = $obj-&gt;dump_log;

    $fh = $obj-&gt;dump_log($fh);

    $fh = $obj-&gt;dump_log($tiefh);

    $fh = $obj-&gt;dump_log($filename);</code></pre>

<p>This method starts or stops dump format logging of all the object&#39;s input and output. The dump format shows the blocks read and written in a hexadecimal and printable character format. This method is useful when debugging, however you might want to first try <code>input_log()</code> as it&#39;s more readable.</p>

<p>If no argument is given, the log filehandle is returned. A returned empty string indicates logging is off.</p>

<p>To stop logging, use an empty string as an argument. The stopped filehandle is not closed.</p>

<p>If an open filehandle is given, it is used for logging and returned. Otherwise, the argument is assumed to be the name of a file, the filename is opened for logging and a filehandle to it is returned. If the filehandle is not already opened or the filename can&#39;t be opened for writing, the error mode action is performed. The filehandle can be a tied filehandle.</p>

</dd>
</dl>

<dl>

<dt id="eof-end-of-file-indicator"><a id="eof"></a><b>eof</b> - end of file indicator</dt>
<dd>

<pre><code>    $eof = $obj-&gt;eof;</code></pre>

<p>This method returns <code>1</code> if end of file has been read, otherwise it returns an empty string. Because the input is buffered this isn&#39;t the same thing as <i>$obj</i> has closed. In other words <i>$obj</i> can be closed but there still can be stuff in the buffer to be read. Under this condition you can still read but you won&#39;t be able to write.</p>

</dd>
</dl>

<dl>

<dt id="errmode-define-action-to-be-performed-on-error"><a id="errmode"></a><b>errmode</b> - define action to be performed on error</dt>
<dd>

<pre><code>    $mode = $obj-&gt;errmode;

    $prev = $obj-&gt;errmode($mode);</code></pre>

<p>This method gets or sets the action used when errors are encountered using the object. The first calling sequence returns the current error mode. The second calling sequence sets it to <i>$mode</i> and returns the previous mode. Valid values for <i>$mode</i> are <code>&quot;die&quot;</code> (the default), <code>&quot;return&quot;</code>, a <i>coderef</i>, or an <i>arrayref</i>.</p>

<p>When mode is <code>&quot;die&quot;</code> and an error is encountered using the object, then an error message is printed to standard error and the program dies.</p>

<p>When mode is <code>&quot;return&quot;</code> then the method generating the error places an error message in the object and returns an undefined value in a scalar context and an empty list in list context. The error message may be obtained using <code>errmsg()</code>.</p>

<p>When mode is a <i>coderef</i>, then when an error is encountered <i>coderef</i> is called with the error message as its first argument. Using this mode you may have your own subroutine handle errors. If <i>coderef</i> itself returns then the method generating the error returns undefined or an empty list depending on context.</p>

<p>When mode is an <i>arrayref</i>, the first element of the array must be a <i>coderef</i>. Any elements that follow are the arguments to <i>coderef</i>. When an error is encountered, the <i>coderef</i> is called with its arguments. Using this mode you may have your own subroutine handle errors. If the <i>coderef</i> itself returns then the method generating the error returns undefined or an empty list depending on context.</p>

<p>A warning is printed to STDERR when attempting to set this attribute to something that is not <code>&quot;die&quot;</code>, <code>&quot;return&quot;</code>, a <i>coderef</i>, or an <i>arrayref</i> whose first element isn&#39;t a <i>coderef</i>.</p>

</dd>
</dl>

<dl>

<dt id="errmsg-most-recent-error-message"><a id="errmsg"></a><b>errmsg</b> - most recent error message</dt>
<dd>

<pre><code>    $msg = $obj-&gt;errmsg;

    $prev = $obj-&gt;errmsg(@msgs);</code></pre>

<p>The first calling sequence returns the error message associated with the object. The empty string is returned if no error has been encountered yet. The second calling sequence sets the error message for the object to the concatenation of <i>@msgs</i> and returns the previous error message. Normally, error messages are set internally by a method when an error is encountered.</p>

</dd>
</dl>

<dl>

<dt id="error-perform-the-error-mode-action"><a id="error"></a><b>error</b> - perform the error mode action</dt>
<dd>

<pre><code>    $obj-&gt;error(@msgs);</code></pre>

<p>This method concatenates <i>@msgs</i> into a string and places it in the object as the error message. Also see <code>errmsg()</code>. It then performs the error mode action. Also see <code>errmode()</code>.</p>

<p>If the error mode doesn&#39;t cause the program to die, then an undefined value or an empty list is returned depending on the context.</p>

<p>This method is primarily used by this class or a sub-class to perform the user requested action when an error is encountered.</p>

</dd>
</dl>

<dl>

<dt id="family-IP-address-family-for-remote-host"><a id="family"></a><b>family</b> - IP address family for remote host</dt>
<dd>

<pre><code>    $family = $obj-&gt;family;

    $prev   = $obj-&gt;family($family);</code></pre>

<p>This method designates which IP address family <code>host()</code> refers to, i.e. IPv4 or IPv6. IPv6 support is available when using perl 5.14 or later. With no argument it returns the current value set in the object. With an argument it sets the current address family to <i>$family</i> and returns the previous address family. Valid values are <code>&quot;ipv4&quot;</code>, <code>&quot;ipv6&quot;</code>, or <code>&quot;any&quot;</code>. When <code>&quot;any&quot;</code>, the <code>host()</code> can be a hostname or IP address for either IPv4 or IPv6. After connecting, you can use <code>sockfamily()</code> to determine which IP address family was used.</p>

<p>The default value is <code>&quot;ipv4&quot;</code>.</p>

<p>The error mode action is performed when attempting to set this attribute to something that isn&#39;t <code>&quot;ipv4&quot;</code>, <code>&quot;ipv6&quot;</code>, or <code>&quot;any&quot;</code>. It is also performed when attempting to set it to <code>&quot;ipv6&quot;</code> when the Socket module is less than version 1.94 or IPv6 is not supported in the OS as indicated by Socket::AF_INET6 not being defined.</p>

</dd>
</dl>

<dl>

<dt id="fhopen-use-already-open-filehandle-for-I/O"><a id="fhopen"></a><a id="fhopen-use-already-open-filehandle-for-I-O"></a><b>fhopen</b> - use already open filehandle for I/O</dt>
<dd>

<pre><code>    $ok = $obj-&gt;fhopen($fh);</code></pre>

<p>This method associates the open filehandle <i>$fh</i> with <i>$obj</i> for further I/O. Filehandle <i>$fh</i> must already be opened.</p>

<p>Suppose you want to use the features of this module to do I/O to something other than a TCP port, for example STDIN or a filehandle opened to read from a process. Instead of opening the object for I/O to a TCP port by using <code>open()</code> or <code>new()</code>, call this method instead.</p>

<p>The value <code>1</code> is returned success, the error mode action is performed on failure.</p>

</dd>
</dl>

<dl>

<dt id="get-read-block-of-data"><a id="get"></a><b>get</b> - read block of data</dt>
<dd>

<pre><code>    $data = $obj-&gt;get([Binmode    =&gt; $mode,]
                      [Errmode    =&gt; $errmode,]
                      [Telnetmode =&gt; $mode,]
                      [Timeout    =&gt; $secs,]);</code></pre>

<p>This method reads a block of data from the object and returns it along with any buffered data. If no buffered data is available to return, it will wait for data to read using the timeout specified in the object. You can override that timeout using <i>$secs</i>. Also see <code>timeout()</code>. If buffered data is available to return, it also checks for a block of data that can be immediately read.</p>

<p>On eof an undefined value is returned. On time-out or other failures, the error mode action is performed. To distinguish between eof or an error occurring when the error mode is not set to <code>&quot;die&quot;</code>, use <code>eof()</code>.</p>

<p>Optional named parameters are provided to override the current settings of binmode, errmode, telnetmode, and timeout.</p>

</dd>
</dl>

<dl>

<dt id="getline-read-next-line"><a id="getline"></a><b>getline</b> - read next line</dt>
<dd>

<pre><code>    $line = $obj-&gt;getline([Binmode    =&gt; $mode,]
                          [Errmode    =&gt; $errmode,]
                          [Input_record_separator =&gt; $chars,]
                          [Rs         =&gt; $chars,]
                          [Telnetmode =&gt; $mode,]
                          [Timeout    =&gt; $secs,]);</code></pre>

<p>This method reads and returns the next line of data from the object. You can use <code>input_record_separator()</code> to change the notion of what separates a line. The default is <code>&quot;\n&quot;</code>. If a line isn&#39;t immediately available, this method blocks waiting for a line or a time-out.</p>

<p>On eof an undefined value is returned. On time-out or other failures, the error mode action is performed. To distinguish between eof or an error occurring when the error mode is not set to <code>&quot;die&quot;</code>, use <code>eof()</code>.</p>

<p>Optional named parameters are provided to override the current settings of binmode, errmode, input_record_separator, rs, telnetmode, and timeout. Rs is synonymous with input_record_separator.</p>

</dd>
</dl>

<dl>

<dt id="getlines-read-next-lines"><a id="getlines"></a><b>getlines</b> - read next lines</dt>
<dd>

<pre><code>    @lines = $obj-&gt;getlines([Binmode    =&gt; $mode,]
                            [Errmode    =&gt; $errmode,]
                            [Input_record_separator =&gt; $chars,]
                            [Rs         =&gt; $chars,]
                            [Telnetmode =&gt; $mode,]
                            [Timeout    =&gt; $secs,]
                            [All        =&gt; $boolean,]);</code></pre>

<p>This method reads and returns all the lines of data from the object until end of file is read. You can use <code>input_record_separator()</code> to change the notion of what separates a line. The default is <code>&quot;\n&quot;</code>. A time-out error occurs if all the lines can&#39;t be read within the time-out interval. See <code>timeout()</code>.</p>

<p>The behavior of this method was changed in version 3.03. Prior to version 3.03 this method returned just the lines available from the next read. To get that old behavior, use the optional named parameter <i>All</i> and set <i>$boolean</i> to <code>&quot;&quot;</code> or <code>0</code>.</p>

<p>If only eof is read then an empty list is returned. On time-out or other failures, the error mode action is performed. Use <code>eof()</code> to distinguish between reading only eof or an error occurring when the error mode is not set to <code>&quot;die&quot;</code>.</p>

<p>Optional named parameters are provided to override the current settings of binmode, errmode, input_record_separator, rs, telnetmode, and timeout. Rs is synonymous with input_record_separator.</p>

</dd>
</dl>

<dl>

<dt id="host-name-or-IP-address-of-remote-host"><a id="host"></a><b>host</b> - name or IP address of remote host</dt>
<dd>

<pre><code>    $host = $obj-&gt;host;

    $prev = $obj-&gt;host($host);</code></pre>

<p>This method designates the remote host for <code>open()</code>. It is either a hostname or an IP address. With no argument it returns the current value set in the object. With an argument it sets the current host name to <i>$host</i> and returns the previous value. Use <code>family()</code> to control which IP address family, IPv4 or IPv6, host refers to.</p>

<p>The default value is <code>&quot;localhost&quot;</code>. It may also be set by <code>open()</code> or <code>new()</code>.</p>

</dd>
</dl>

<dl>

<dt id="input_log-log-all-input"><a id="input_log"></a><b>input_log</b> - log all input</dt>
<dd>

<pre><code>    $fh = $obj-&gt;input_log;

    $fh = $obj-&gt;input_log($fh);

    $fh = $obj-&gt;input_log($tiefh);

    $fh = $obj-&gt;input_log($filename);</code></pre>

<p>This method starts or stops logging of input. This is useful when debugging. Also see <code>dump_log()</code>. Because most command interpreters echo back commands received, it&#39;s likely all your output will also be in this log. Note that input logging occurs after newline translation. See <code>binmode()</code> for details on newline translation.</p>

<p>If no argument is given, the log filehandle is returned. A returned empty string indicates logging is off.</p>

<p>To stop logging, use an empty string as an argument. The stopped filehandle is not closed.</p>

<p>If an open filehandle is given, it is used for logging and returned. Otherwise, the argument is assumed to be the name of a file, the filename is opened for logging and a filehandle to it is returned. If the filehandle is not already opened or the filename can&#39;t be opened for writing, the error mode action is performed. The filehandle can be a tied filehandle.</p>

</dd>
</dl>

<dl>

<dt id="input_record_separator-input-line-delimiter"><a id="input_record_separator"></a><b>input_record_separator</b> - input line delimiter</dt>
<dd>

<pre><code>    $chars = $obj-&gt;input_record_separator;

    $prev = $obj-&gt;input_record_separator($chars);</code></pre>

<p>This method designates the line delimiter for input. It&#39;s used with <code>getline()</code>, <code>getlines()</code>, and <code>cmd()</code> to determine lines in the input.</p>

<p>With no argument this method returns the current input record separator set in the object. With an argument it sets the input record separator to <i>$chars</i> and returns the previous value. Note that <i>$chars</i> must have length.</p>

<p>A warning is printed to STDERR when attempting to set this attribute to a string with no length.</p>

</dd>
</dl>

<dl>

<dt id="last_prompt-last-prompt-read"><a id="last_prompt"></a><b>last_prompt</b> - last prompt read</dt>
<dd>

<pre><code>    $string = $obj-&gt;last_prompt;

    $prev = $obj-&gt;last_prompt($string);</code></pre>

<p>With no argument this method returns the last prompt read by cmd() or login(). See <code>prompt()</code>. With an argument it sets the last prompt read to <i>$string</i> and returns the previous value. Normally, only internal methods set the last prompt.</p>

</dd>
</dl>

<dl>

<dt id="lastline-last-line-read"><a id="lastline"></a><b>lastline</b> - last line read</dt>
<dd>

<pre><code>    $line = $obj-&gt;lastline;

    $prev = $obj-&gt;lastline($line);</code></pre>

<p>This method retrieves the last line read from the object. This may be a useful error message when the remote side abnormally closes the connection. Typically the remote side will print an error message before closing.</p>

<p>With no argument this method returns the last line read from the object. With an argument it sets the last line read to <i>$line</i> and returns the previous value. Normally, only internal methods set the last line.</p>

</dd>
</dl>

<dl>

<dt id="localfamily-IP-address-family-for-local-host"><a id="localfamily"></a><b>localfamily</b> - IP address family for local host</dt>
<dd>

<pre><code>    $localfamily = $obj-&gt;localfamily;

    $prev   = $obj-&gt;localfamily($family);</code></pre>

<p>This method designates which IP address family <code>localhost()</code> refers to, i.e. IPv4 or IPv6. IPv6 support is available when using perl 5.14 or later. With no argument it returns the current value set in the object. With an argument it sets the current local address family to <i>$family</i> and returns the previous address family. Valid values are <code>&quot;ipv4&quot;</code>, <code>&quot;ipv6&quot;</code>, or <code>&quot;any&quot;</code>. When <code>&quot;any&quot;</code>, the <code>localhost()</code> can be a hostname or IP address for either IPv4 or IPv6.</p>

<p>The default value is <code>&quot;ipv4&quot;</code>.</p>

<p>The error mode action is performed when attempting to set this attribute to something that isn&#39;t <code>&quot;ipv4&quot;</code>, <code>&quot;ipv6&quot;</code>, or <code>&quot;any&quot;</code>. It is also performed when attempting to set it to <code>&quot;ipv6&quot;</code> when the Socket module is less than version 1.94 or IPv6 is not supported in the OS as indicated by Socket::AF_INET6 not being defined.</p>

</dd>
</dl>

<dl>

<dt id="localhost-bind-local-socket-to-a-specific-network-interface"><a id="localhost"></a><b>localhost</b> - bind local socket to a specific network interface</dt>
<dd>

<pre><code>    $localhost = $obj-&gt;localhost;

    $prev = $obj-&gt;localhost($host);</code></pre>

<p>This method designates the local socket IP address for <code>open()</code>. It is either a hostname, an IP address, or a null string (i.e. <code>&quot;&quot;</code>). A null string disables this feature.</p>

<p>Normally the OS picks which local network interface to use. This method is useful when the local machine has more than one network interface and you want to bind to a specific one. With no argument it returns the current value set in the object. With an argument it sets the current local host name to <i>$host</i> and returns the previous value. Use <code>localfamily()</code> to control which IP address family, IPv4 or IPv6, local host refers to.</p>

<p>The default value is <code>&quot;&quot;</code>.</p>

</dd>
</dl>

<dl>

<dt id="login-perform-standard-login"><a id="login"></a><b>login</b> - perform standard login</dt>
<dd>

<pre><code>    $ok = $obj-&gt;login($username, $password);

    $ok = $obj-&gt;login(Name     =&gt; $username,
                      Password =&gt; $password,
                      [Errmode =&gt; $mode,]
                      [Prompt  =&gt; $match,]
                      [Timeout =&gt; $secs,]);</code></pre>

<p>This method performs a standard login by waiting for a login prompt and responding with <i>$username</i>, then waiting for the password prompt and responding with <i>$password</i>, and then waiting for the command interpreter prompt. If any of those prompts sent by the remote side don&#39;t match what&#39;s expected, this method will time-out, unless timeout is turned off.</p>

<p>Login prompt must match either of these case insensitive patterns:</p>

<pre><code>    /login[: ]*$/i
    /username[: ]*$/i</code></pre>

<p>Password prompt must match this case insensitive pattern:</p>

<pre><code>    /password[: ]*$/i</code></pre>

<p>The command interpreter prompt must match the current setting of prompt. See <code>prompt()</code>.</p>

<p>Use <code>dump_log()</code> to debug when this method keeps timing-out and you don&#39;t think it should.</p>

<p>Consider using a combination of <code>print()</code> and <code>waitfor()</code> as an alternative to this method when it doesn&#39;t do what you want, e.g. the remote host doesn&#39;t prompt for a username.</p>

<p>On success, <code>1</code> is returned. On time out, eof, or other failures, the error mode action is performed. See <code>errmode()</code>.</p>

<p>Optional named parameters are provided to override the current settings of errmode, prompt, and timeout.</p>

</dd>
</dl>

<dl>

<dt id="max_buffer_length-maximum-size-of-input-buffer"><a id="max_buffer_length"></a><b>max_buffer_length</b> - maximum size of input buffer</dt>
<dd>

<pre><code>    $len = $obj-&gt;max_buffer_length;

    $prev = $obj-&gt;max_buffer_length($len);</code></pre>

<p>This method designates the maximum size of the input buffer. An error is generated when a read causes the buffer to exceed this limit. The default value is 1,048,576 bytes (1 MiB). The input buffer can grow much larger than the block size when you continuously read using <code>getline()</code> or <code>waitfor()</code> and the data stream contains no newlines or matching waitfor patterns.</p>

<p>With no argument, this method returns the current maximum buffer length set in the object. With an argument it sets the maximum buffer length to <i>$len</i> and returns the previous value. Values of <i>$len</i> smaller than 512 will be adjusted to 512.</p>

<p>A warning is printed to STDERR when attempting to set this attribute to something that isn&#39;t a positive integer.</p>

</dd>
</dl>

<dl>

<dt id="ofs-field-separator-for-print"><a id="ofs"></a><b>ofs</b> - field separator for print</dt>
<dd>

<pre><code>    $chars = $obj-&gt;ofs

    $prev = $obj-&gt;ofs($chars);</code></pre>

<p>This method is synonymous with <code>output_field_separator()</code>.</p>

</dd>
</dl>

<dl>

<dt id="open-connect-to-port-on-remote-host"><a id="open"></a><b>open</b> - connect to port on remote host</dt>
<dd>

<pre><code>    $ok = $obj-&gt;open($host);

    $ok = $obj-&gt;open([Host        =&gt; $host,]
                     [Port        =&gt; $port,]
                     [Family      =&gt; $family,]
                     [Errmode     =&gt; $mode,]
                     [Timeout     =&gt; $secs,]
                     [Localhost   =&gt; $host,]
                     [Localfamily =&gt; $family,]);</code></pre>

<p>This method opens a TCP connection to <i>$port</i> on <i>$host</i> for the IP address <i>$family</i>. If any of those arguments are missing then the current attribute value for the object is used. Specifying <i>Host</i> sets that attribute for the object. Specifying any of the other optional named parameters overrides the current setting.</p>

<p>The default IP address family is <code>&quot;ipv4&quot;</code>. <i>$family</i> may be set to <code>&quot;ipv4&quot;</code>, <code>&quot;ipv6&quot;</code>, or <code>&quot;any&quot;</code>. See <code>family()</code> for more details.</p>

<p><i>Localhost</i> is used to bind to a specific local network interface.</p>

<p>If the object is already open, it is closed before attempting a connection.</p>

<p>On success <code>1</code> is returned. On time-out or other connection failures, the error mode action is performed. See <code>errmode()</code>.</p>

<p>Time-outs don&#39;t work for this method on machines that don&#39;t implement SIGALRM - most notably MS-Windows machines. For those machines, an error is returned when the system reaches its own time-out while trying to connect.</p>

<p>A side effect of this method is to reset the alarm interval associated with SIGALRM.</p>

</dd>
</dl>

<dl>

<dt id="option_accept-indicate-willingness-to-accept-a-TELNET-option"><a id="option_accept"></a><b>option_accept</b> - indicate willingness to accept a TELNET option</dt>
<dd>

<pre><code>    $fh = $obj-&gt;option_accept([Do   =&gt; $telopt,]
                              [Dont =&gt; $telopt,]
                              [Will =&gt; $telopt,]
                              [Wont =&gt; $telopt,]);</code></pre>

<p>This method is used to indicate whether to accept or reject an offer to enable a TELNET option made by the remote side. If you&#39;re using <i>Do</i> or <i>Will</i> to indicate a willingness to enable, then a notification callback must have already been defined by a prior call to <code>option_callback()</code>. See <code>option_callback()</code> for details on receiving enable/disable notification of a TELNET option.</p>

<p>You can give multiple <i>Do</i>, <i>Dont</i>, <i>Will</i>, or <i>Wont</i> arguments for different TELNET options in the same call to this method.</p>

<p>The following example describes the meaning of the named parameters. A TELNET option, such as <code>TELOPT_ECHO</code> used below, is an integer constant that you can import from Net::Telnet. See the source in file Telnet.pm for the complete list.</p>

<ul>

<li><p><i>Do</i> =&gt; <code>TELOPT_ECHO</code></p>

<ul>

<li><p>we&#39;ll accept an offer to enable the echo option on the local side</p>

</li>
</ul>

</li>
<li><p><i>Dont</i> =&gt; <code>TELOPT_ECHO</code></p>

<ul>

<li><p>we&#39;ll reject an offer to enable the echo option on the local side</p>

</li>
</ul>

</li>
<li><p><i>Will</i> =&gt; <code>TELOPT_ECHO</code></p>

<ul>

<li><p>we&#39;ll accept an offer to enable the echo option on the remote side</p>

</li>
</ul>

</li>
<li><p><i>Wont</i> =&gt; <code>TELOPT_ECHO</code></p>

<ul>

<li><p>we&#39;ll reject an offer to enable the echo option on the remote side</p>

</li>
</ul>

</li>
<li><p>Use <code>option_send()</code> to send a request to the remote side to enable or disable a particular TELNET option.</p>

</li>
</ul>

</dd>
</dl>

<dl>

<dt id="option_callback-define-the-option-negotiation-callback"><a id="option_callback"></a><b>option_callback</b> - define the option negotiation callback</dt>
<dd>

<pre><code>    $coderef = $obj-&gt;option_callback;

    $prev = $obj-&gt;option_callback($coderef);</code></pre>

<p>This method defines the callback subroutine that is called when a TELNET option is enabled or disabled. Once defined, the <i>option_callback</i> may not be undefined. However, calling this method with a different <i>$coderef</i> changes it.</p>

<p>A warning is printed to STDERR when attempting to set this attribute to something that isn&#39;t a coderef.</p>

<p>Here are the circumstances that invoke <i>$coderef</i>:</p>

<ul>

<li><p>An option becomes enabled because the remote side requested an enable and <code>option_accept()</code> had been used to arrange that it be accepted.</p>

</li>
<li><p>The remote side arbitrarily decides to disable an option that is currently enabled. Note that Net::Telnet always accepts a request to disable from the remote side.</p>

</li>
<li><p><code>option_send()</code> was used to send a request to enable or disable an option and the response from the remote side has just been received. Note, that if a request to enable is rejected then <i>$coderef</i> is still invoked even though the option didn&#39;t change.</p>

</li>
<li><p>Here are the arguments passed to <i>&amp;$coderef</i>:</p>

<pre><code>    &amp;$coderef($obj, $option, $is_remote,
              $is_enabled, $was_enabled, $buf_position);</code></pre>

</li>
</ul>

<ul>

<li><p>1. <i>$obj</i> is the Net::Telnet object</p>

</li>
<li><p>2. <i>$option</i> is the TELNET option. Net::Telnet exports constants for the various TELNET options which just equate to an integer.</p>

</li>
<li><p>3. <i>$is_remote</i> is a boolean indicating for which side the option applies.</p>

</li>
<li><p>4. <i>$is_enabled</i> is a boolean indicating the option is enabled or disabled</p>

</li>
<li><p>5. <i>$was_enabled</i> is a boolean indicating the option was previously enabled or disabled</p>

</li>
<li><p>6. <i>$buf_position</i> is an integer indicating the position in the object&#39;s input buffer where the option takes effect. See <code>buffer()</code> to access the object&#39;s input buffer.</p>

</li>
</ul>

</dd>
</dl>

<dl>

<dt id="option_log-log-all-TELNET-options-sent-or-received"><a id="option_log"></a><b>option_log</b> - log all TELNET options sent or received</dt>
<dd>

<pre><code>    $fh = $obj-&gt;option_log;

    $fh = $obj-&gt;option_log($fh);

    $fh = $obj-&gt;option_log($tiefh);

    $fh = $obj-&gt;option_log($filename);</code></pre>

<p>This method starts or stops logging of all TELNET options being sent or received. This is useful for debugging when you send options via <code>option_send()</code> or you arrange to accept option requests from the remote side via <code>option_accept()</code>. Also see <code>dump_log()</code>.</p>

<p>If no argument is given, the log filehandle is returned. An empty string indicates logging is off.</p>

<p>To stop logging, use an empty string as an argument. The stopped filehandle is not closed.</p>

<p>If an open filehandle is given, it is used for logging and returned. Otherwise, the argument is assumed to be the name of a file, the filename is opened for logging and a filehandle to it is returned. If the filehandle is not already opened or the filename can&#39;t be opened for writing, the error mode action is performed. The filehandle can be a tied filehandle.</p>

</dd>
</dl>

<dl>

<dt id="option_send-send-TELNET-option-negotiation-request"><a id="option_send"></a><b>option_send</b> - send TELNET option negotiation request</dt>
<dd>

<pre><code>    $ok = $obj-&gt;option_send([Do    =&gt; $telopt,]
                            [Dont  =&gt; $telopt,]
                            [Will  =&gt; $telopt,]
                            [Wont  =&gt; $telopt,]
                            [Async =&gt; $boolean,]);</code></pre>

<p>This method is not yet implemented. Look for it in a future version.</p>

</dd>
</dl>

<dl>

<dt id="option_state-get-current-state-of-a-TELNET-option"><a id="option_state"></a><b>option_state</b> - get current state of a TELNET option</dt>
<dd>

<pre><code>    $hashref = $obj-&gt;option_state($telopt);</code></pre>

<p>This method returns a hashref containing a copy of the current state of TELNET option <i>$telopt</i>.</p>

<p>Here are the values returned in the hash:</p>

<ul>

<li><p><i>$hashref</i>-&gt;{remote_enabled}</p>

<ul>

<li><p>boolean that indicates if the option is enabled on the remote side.</p>

</li>
</ul>

</li>
<li><p><i>$hashref</i>-&gt;{remote_enable_ok}</p>

<ul>

<li><p>boolean that indicates if it&#39;s ok to accept an offer to enable this option on the remote side.</p>

</li>
</ul>

</li>
<li><p><i>$hashref</i>-&gt;{remote_state}</p>

<ul>

<li><p>string used to hold the internal state of option negotiation for this option on the remote side.</p>

</li>
</ul>

</li>
<li><p><i>$hashref</i>-&gt;{local_enabled}</p>

<ul>

<li><p>boolean that indicates if the option is enabled on the local side.</p>

</li>
</ul>

</li>
<li><p><i>$hashref</i>-&gt;{local_enable_ok}</p>

<ul>

<li><p>boolean that indicates if it&#39;s ok to accept an offer to enable this option on the local side.</p>

</li>
</ul>

</li>
<li><p><i>$hashref</i>-&gt;{local_state}</p>

<ul>

<li><p>string used to hold the internal state of option negotiation for this option on the local side.</p>

</li>
</ul>

</li>
</ul>

</dd>
</dl>

<dl>

<dt id="ors-output-line-delimiter"><a id="ors"></a><b>ors</b> - output line delimiter</dt>
<dd>

<pre><code>    $chars = $obj-&gt;ors;

    $prev = $obj-&gt;ors($chars);</code></pre>

<p>This method is synonymous with <code>output_record_separator()</code>.</p>

</dd>
</dl>

<dl>

<dt id="output_field_separator-field-separator-for-print"><a id="output_field_separator"></a><b>output_field_separator</b> - field separator for print</dt>
<dd>

<pre><code>    $chars = $obj-&gt;output_field_separator;

    $prev = $obj-&gt;output_field_separator($chars);</code></pre>

<p>This method designates the output field separator for <code>print()</code>. Ordinarily the print method simply prints out the comma separated fields you specify. Set this to specify what&#39;s printed between fields.</p>

<p>With no argument this method returns the current output field separator set in the object. With an argument it sets the output field separator to <i>$chars</i> and returns the previous value.</p>

<p>By default it&#39;s set to an empty string.</p>

</dd>
</dl>

<dl>

<dt id="output_log-log-all-output"><a id="output_log"></a><b>output_log</b> - log all output</dt>
<dd>

<pre><code>    $fh = $obj-&gt;output_log;

    $fh = $obj-&gt;output_log($fh);

    $fh = $obj-&gt;output_log($tiefh);

    $fh = $obj-&gt;output_log($filename);</code></pre>

<p>This method starts or stops logging of output. This is useful when debugging. Also see <code>dump_log()</code>. Because most command interpreters echo back commands received, it&#39;s likely all your output would also be in an input log. See <code>input_log()</code>. Note that output logging occurs before newline translation. See <code>binmode()</code> for details on newline translation.</p>

<p>If no argument is given, the log filehandle is returned. A returned empty string indicates logging is off.</p>

<p>To stop logging, use an empty string as an argument. The stopped filehandle is not closed.</p>

<p>If an open filehandle is given, it is used for logging and returned. Otherwise, the argument is assumed to be the name of a file, the filename is opened for logging and a filehandle to it is returned. If the filehandle is not already opened or the filename can&#39;t be opened for writing, the error mode action is performed. The filehandle can be a tied filehandle.</p>

</dd>
</dl>

<dl>

<dt id="output_record_separator-output-line-delimiter"><a id="output_record_separator"></a><b>output_record_separator</b> - output line delimiter</dt>
<dd>

<pre><code>    $chars = $obj-&gt;output_record_separator;

    $prev = $obj-&gt;output_record_separator($chars);</code></pre>

<p>This method designates the output line delimiter for <code>print()</code> and <code>cmd()</code>. Set this to specify what&#39;s printed at the end of <code>print()</code> and <code>cmd()</code>.</p>

<p>The output record separator is set to <code>&quot;\n&quot;</code> by default, so there&#39;s no need to append all your commands with a newline. To avoid printing the output_record_separator use <code>put()</code> or set the output_record_separator to an empty string.</p>

<p>With no argument this method returns the current output record separator set in the object. With an argument it sets the output record separator to <i>$chars</i> and returns the previous value.</p>

</dd>
</dl>

<dl>

<dt id="peerhost-IP-address-of-the-other-end-of-the-socket-connection"><a id="peerhost"></a><b>peerhost</b> - IP address of the other end of the socket connection</dt>
<dd>

<pre><code>    $ipaddr = $obj-&gt;peerhost;</code></pre>

<p>This method returns a string which is the IPv4 or IPv6 address the remote socket is bound to (i.e. it is the IP address of <code>host()</code>). It returns <code>&quot;&quot;</code> when not connected.</p>

</dd>
</dl>

<dl>

<dt id="peerport-TCP-port-of-the-other-end-of-the-socket-connection"><a id="peerport"></a><b>peerport</b> - TCP port of the other end of the socket connection</dt>
<dd>

<pre><code>    $port = $obj-&gt;peerport;</code></pre>

<p>This method returns the port number which the remote socket is bound to. It is the same as the <code>port()</code> number when connected. It returns <code>&quot;&quot;</code> when not connected.</p>

</dd>
</dl>

<dl>

<dt id="port-remote-port"><a id="port"></a><b>port</b> - remote port</dt>
<dd>

<pre><code>    $port = $obj-&gt;port;

    $prev = $obj-&gt;port($port);</code></pre>

<p>This method designates the remote TCP port for <code>open()</code>. With no argument this method returns the current port number. With an argument it sets the current port number to <i>$port</i> and returns the previous port. If <i>$port</i> is a TCP service name, then it&#39;s first converted to a port number using the perl function <code>getservbyname()</code>.</p>

<p>The default value is <code>23</code>.</p>

<p>The error mode action is performed when attempting to set this attribute to something that is not a positive integer or a valid TCP service name.</p>

</dd>
</dl>

<dl>

<dt id="print-write-to-object"><a id="print"></a><b>print</b> - write to object</dt>
<dd>

<pre><code>    $ok = $obj-&gt;print(@list);</code></pre>

<p>This method writes <i>@list</i> followed by the <i>output_record_separator</i> to the open object and returns <code>1</code> if all data was successfully written. On time-out or other failures, the error mode action is performed. See <code>errmode()</code>.</p>

<p>By default, the <code>output_record_separator()</code> is set to <code>&quot;\n&quot;</code> so all your commands automatically end with a newline. In most cases your output is being read by a command interpreter which won&#39;t accept a command until newline is read. This is similar to someone typing a command and hitting the return key. To avoid printing a trailing <code>&quot;\n&quot;</code> use <code>put()</code> instead or set the output_record_separator to an empty string.</p>

<p>On failure, it&#39;s possible that some data was written. If you choose to try and recover from a print timing-out, use <code>print_length()</code> to determine how much was written before the error occurred.</p>

<p>You may also use the output field separator to print a string between the list elements. See <code>output_field_separator()</code>.</p>

</dd>
</dl>

<dl>

<dt id="print_length-number-of-bytes-written-by-print"><a id="print_length"></a><b>print_length</b> - number of bytes written by print</dt>
<dd>

<pre><code>    $num = $obj-&gt;print_length;</code></pre>

<p>This returns the number of bytes successfully written by the most recent <code>print()</code> or <code>put()</code>.</p>

</dd>
</dl>

<dl>

<dt id="prompt-pattern-to-match-a-prompt"><a id="prompt"></a><b>prompt</b> - pattern to match a prompt</dt>
<dd>

<pre><code>    $matchop = $obj-&gt;prompt;

    $prev = $obj-&gt;prompt($matchop);</code></pre>

<p>This method sets the pattern used to find a prompt in the input stream. It must be a string representing a valid perl pattern match operator. The methods <code>login()</code> and <code>cmd()</code> try to read until matching the prompt. They will fail with a time-out error if the pattern you&#39;ve chosen doesn&#39;t match what the remote side sends.</p>

<p>With no argument this method returns the prompt set in the object. With an argument it sets the prompt to <i>$matchop</i> and returns the previous value.</p>

<p>The default prompt is <code>&#39;/[\$%#&gt;] $/&#39;</code></p>

<p>Always use single quotes, instead of double quotes, to construct <i>$matchop</i> (e.g. <code>&#39;/bash\$ $/&#39;</code>). If you&#39;re constructing a DOS like file path, you&#39;ll need to use four backslashes to represent one (e.g. <code>&#39;/c:\\\\users\\\\bill&gt;$/i&#39;</code>).</p>

<p>Of course don&#39;t forget about regexp metacharacters like <code>.</code>, <code>[</code>, or <code>$</code>. You&#39;ll only need a single backslash to quote them. The anchor metacharacters <code>^</code> and <code>$</code> refer to positions in the input buffer.</p>

<p>The error mode action is performed when attempting to set this attribute with a match operator missing its opening delimiter.</p>

</dd>
</dl>

<dl>

<dt id="put-write-to-object"><a id="put"></a><b>put</b> - write to object</dt>
<dd>

<pre><code>    $ok = $obj-&gt;put($string);

    $ok = $obj-&gt;put(String      =&gt; $string,
                    [Binmode    =&gt; $mode,]
                    [Errmode    =&gt; $errmode,]
                    [Telnetmode =&gt; $mode,]
                    [Timeout    =&gt; $secs,]);</code></pre>

<p>This method writes <i>$string</i> to the opened object and returns <code>1</code> if all data was successfully written. This method is like <code>print()</code> except that it doesn&#39;t write the trailing output_record_separator (&quot;\n&quot; by default). On time-out or other failures, the error mode action is performed. See <code>errmode()</code>.</p>

<p>On failure, it&#39;s possible that some data was written. If you choose to try and recover from a put timing-out, use <code>print_length()</code> to determine how much was written before the error occurred.</p>

<p>Optional named parameters are provided to override the current settings of binmode, errmode, telnetmode, and timeout.</p>

</dd>
</dl>

<dl>

<dt id="rs-input-line-delimiter"><a id="rs"></a><b>rs</b> - input line delimiter</dt>
<dd>

<pre><code>    $chars = $obj-&gt;rs;

    $prev = $obj-&gt;rs($chars);</code></pre>

<p>This method is synonymous with <code>input_record_separator()</code>.</p>

</dd>
</dl>

<dl>

<dt id="sockfamily-IP-address-family-of-connected-local-socket"><a id="sockfamily"></a><b>sockfamily</b> - IP address family of connected local socket</dt>
<dd>

<pre><code>    $sockfamily = $obj-&gt;sockfamily;</code></pre>

<p>This method returns which IP address family <code>open()</code> used to successfully connect. It is most useful when the requested address <code>family()</code> for <code>open()</code> was <code>&quot;any&quot;</code>. Values returned may be <code>&quot;ipv4&quot;</code>, <code>&quot;ipv6&quot;</code>, or <code>&quot;&quot;</code> (when not connected).</p>

</dd>
</dl>

<dl>

<dt id="sockhost-IP-address-of-this-end-of-the-socket-connection"><a id="sockhost"></a><b>sockhost</b> - IP address of this end of the socket connection</dt>
<dd>

<pre><code>    $ipaddr = $obj-&gt;sockhost;</code></pre>

<p>This method returns a string which is the IPv4 or IPv6 address the local socket is bound to. It returns <code>&quot;&quot;</code> when not connected.</p>

</dd>
</dl>

<dl>

<dt id="sockport-TCP-port-of-this-end-of-the-socket-connection"><a id="sockport"></a><b>sockport</b> - TCP port of this end of the socket connection</dt>
<dd>

<pre><code>    $port = $obj-&gt;sockport;</code></pre>

<p>This method returns the port number which the local socket is bound to. It returns <code>&quot;&quot;</code> when not connected.</p>

</dd>
</dl>

<dl>

<dt id="telnetmode-turn-off/on-telnet-command-interpretation"><a id="telnetmode"></a><a id="telnetmode-turn-off-on-telnet-command-interpretation"></a><b>telnetmode</b> - turn off/on telnet command interpretation</dt>
<dd>

<pre><code>    $mode = $obj-&gt;telnetmode;

    $prev = $obj-&gt;telnetmode($mode);</code></pre>

<p>This method controls whether or not TELNET commands in the data stream are recognized and handled. The TELNET protocol uses certain character sequences sent in the data stream to control the session. If the port you&#39;re connecting to isn&#39;t using the TELNET protocol, then you should turn this mode off. The default is <i>on</i>.</p>

<p>If no argument is given, the current mode is returned.</p>

<p>If <i>$mode</i> is <code>0</code> then telnet mode is off. If <i>$mode</i> is <code>1</code> then telnet mode is on.</p>

</dd>
</dl>

<dl>

<dt id="timed_out-time-out-indicator"><a id="timed_out"></a><b>timed_out</b> - time-out indicator</dt>
<dd>

<pre><code>    $boolean = $obj-&gt;timed_out;

    $prev = $obj-&gt;timed_out($boolean);</code></pre>

<p>This method indicates if a previous read, write, or open method timed-out. Remember that timing-out is itself an error. To be able to invoke <code>timed_out()</code> after a time-out error, you&#39;d have to change the default error mode to something other than <code>&quot;die&quot;</code>. See <code>errmode()</code>.</p>

<p>With no argument this method returns <code>1</code> if the previous method timed-out. With an argument it sets the indicator. Normally, only internal methods set this indicator.</p>

</dd>
</dl>

<dl>

<dt id="timeout-I/O-time-out-interval"><a id="timeout"></a><a id="timeout-I-O-time-out-interval"></a><b>timeout</b> - I/O time-out interval</dt>
<dd>

<pre><code>    $secs = $obj-&gt;timeout;

    $prev = $obj-&gt;timeout($secs);</code></pre>

<p>This method sets the timeout interval used when performing I/O or connecting to a port. When a method doesn&#39;t complete within the timeout interval then it&#39;s an error and the error mode action is performed.</p>

<p>A timeout may be expressed as a relative or absolute value. If <i>$secs</i> is greater than or equal to the time the program started, as determined by $^T, then it&#39;s an absolute time value for when time-out occurs. The perl function <code>time()</code> may be used to obtain an absolute time value. For a relative time-out value less than $^T, time-out happens <i>$secs</i> from when the method begins.</p>

<p>If <i>$secs</i> is <code>0</code> then time-out occurs if the data cannot be immediately read or written. Use the undefined value to turn off timing-out completely.</p>

<p>With no argument this method returns the timeout set in the object. With an argument it sets the timeout to <i>$secs</i> and returns the previous value. The default timeout value is <code>10</code> seconds.</p>

<p>A warning is printed to STDERR when attempting to set this attribute to something that is not an <code>undef</code> or a non-negative integer.</p>

</dd>
</dl>

<dl>

<dt id="waitfor-wait-for-pattern-in-the-input"><a id="waitfor"></a><b>waitfor</b> - wait for pattern in the input</dt>
<dd>

<pre><code>    $ok = $obj-&gt;waitfor($matchop);
    $ok = $obj-&gt;waitfor([Match      =&gt; $matchop,]
                        [String     =&gt; $string,]
                        [Binmode    =&gt; $mode,]
                        [Errmode    =&gt; $errmode,]
                        [Telnetmode =&gt; $mode,]
                        [Timeout    =&gt; $secs,]);

    ($prematch, $match) = $obj-&gt;waitfor($matchop);
    ($prematch, $match) = $obj-&gt;waitfor([Match      =&gt; $matchop,]
                                        [String     =&gt; $string,]
                                        [Binmode    =&gt; $mode,]
                                        [Errmode    =&gt; $errmode,]
                                        [Telnetmode =&gt; $mode,]
                                        [Timeout    =&gt; $secs,]);</code></pre>

<p>This method reads until a pattern match or string is found in the input stream. All the characters before and including the match are removed from the input stream.</p>

<p>In a list context the characters before the match and the matched characters are returned in <i>$prematch</i> and <i>$match</i>. In a scalar context, the matched characters and all characters before it are discarded and <code>1</code> is returned on success. On time-out, eof, or other failures, for both list and scalar context, the error mode action is performed. See <code>errmode()</code>.</p>

<p>You can specify more than one pattern or string by simply providing multiple <i>Match</i> and/or <i>String</i> named parameters. A <i>$matchop</i> must be a string representing a valid Perl pattern match operator. The <i>$string</i> is just a substring to find in the input stream.</p>

<p>Use <code>dump_log()</code> to debug when this method keeps timing-out and you don&#39;t think it should.</p>

<p>An optional named parameter is provided to override the current setting of timeout.</p>

<p>To avoid unexpected backslash interpretation, always use single quotes instead of double quotes to construct a match operator argument for <code>prompt()</code> and <code>waitfor()</code> (e.g. <code>&#39;/bash\$ $/&#39;</code>). If you&#39;re constructing a DOS like file path, you&#39;ll need to use four backslashes to represent one (e.g. <code>&#39;/c:\\\\users\\\\bill&gt;$/i&#39;</code>).</p>

<p>Of course don&#39;t forget about regexp metacharacters like <code>.</code>, <code>[</code>, or <code>$</code>. You&#39;ll only need a single backslash to quote them. The anchor metacharacters <code>^</code> and <code>$</code> refer to positions in the input buffer.</p>

<p>Optional named parameters are provided to override the current settings of binmode, errmode, telnetmode, and timeout.</p>

</dd>
</dl>

<h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1>

<dl>

<dt id="RFC-854"><a id="RFC"></a>RFC 854</dt>
<dd>

<p><span style="white-space: nowrap;">TELNET Protocol Specification</span></p>

<p><span style="white-space: nowrap;">http://tools.ietf.org/html/rfc854</span></p>

</dd>
<dt id="RFC-1143"><a id="RFC1"></a>RFC 1143</dt>
<dd>

<p><span style="white-space: nowrap;">Q Method of Implementing TELNET Option Negotiation</span></p>

<p><span style="white-space: nowrap;">http://tools.ietf.org/html/rfc1143</span></p>

</dd>
<dt id="TELNET-Option-Assignments"><a id="TELNET"></a>TELNET Option Assignments</dt>
<dd>

<p><span style="white-space: nowrap;">http://www.iana.org/assignments/telnet-options</span></p>

</dd>
</dl>

<h1 id="EXAMPLES">EXAMPLES</h1>

<p>Setting <code>prompt()</code> to match a user&#39;s shell prompt can be tricky. This example logs in without knowing the shell prompt and then sets it to match <code>prompt()</code>. It requires /usr/bin/env and /bin/sh on the remote host.</p>

<pre><code>    my $host = &#39;your_destination_host_here&#39;;
    my $user = &#39;your_username_here&#39;;
    my $passwd = &#39;your_password_here&#39;;
    my ($t, @output);

    ## Create a Net::Telnet object.
    use Net::Telnet ();
    $t = new Net::Telnet (Timeout  =&gt; 10);

    ## Connect and login.
    $t-&gt;open($host);

    $t-&gt;waitfor(&#39;/login: ?$/i&#39;);
    $t-&gt;print($user);

    $t-&gt;waitfor(&#39;/password: ?$/i&#39;);
    $t-&gt;print($passwd);

    ## Switch to a known shell, using a known prompt.
    $t-&gt;prompt(&#39;/&lt;xPROMPTx&gt; $/&#39;);
    $t-&gt;errmode(&quot;return&quot;);

    $t-&gt;cmd(&quot;exec /usr/bin/env &#39;PS1=&lt;xPROMPTx&gt; &#39; /bin/sh -i&quot;)
        or die &quot;login failed to remote host $host&quot;;

    $t-&gt;errmode(&quot;die&quot;);

    ## Now you can do cmd() to your heart&#39;s content.
    @output = $t-&gt;cmd(&quot;uname -a&quot;);
    print @output;

    exit;</code></pre>

<p>Usually you want the remote TERM environment variable to be set to something like &quot;dumb&quot; so you don&#39;t read escape sequences meant to be interpreted by a display terminal. It is best to set it via <code>cmd()</code>, or via <code>waitfor()</code> and <code>print()</code>. It is also possible to negotiate the terminal type via telnet. Here is how to do that.</p>

<pre><code>    ## Module import.
    use Net::Telnet qw(TELNET_IAC TELNET_SB TELNET_SE TELOPT_TTYPE);

    ## Global variables.
    my $Term;

    ## Main program.
    {
        my $host = &quot;your_destination_host_here&quot;;
        my $user = &quot;your_username_here&quot;;
        my $passwd = &quot;your_password_here&quot;;
        my $prompt = &#39;/bash\$ $/&#39;;  # your regexp for shell prompt here
        my $t;

        $t = new Net::Telnet (Prompt =&gt; $prompt);

        ## Set up callbacks to negotiate terminal type.
        $t-&gt;option_callback(sub {});
        $t-&gt;suboption_callback(\&amp;subopt_callback);
        $t-&gt;option_accept(Do =&gt; TELOPT_TTYPE);

        ## Login and print value of TERM.
        $Term = &quot;dumb&quot;;
        $t-&gt;open($host);
        $t-&gt;login($user, $passwd);
        print $t-&gt;cmd(&#39;hostname&#39;);
        print &quot;TERM=&quot;, $t-&gt;cmd(&#39;echo $TERM&#39;);
        $t-&gt;close;

        exit;
    } # end main program

    sub subopt_callback {
        my ($t, $option, $parameters) = @_;
        my $telcmd;

        if ($option == TELOPT_TTYPE) {
            $telcmd = pack(&quot;C4 A* C2&quot;, TELNET_IAC, TELNET_SB, TELOPT_TTYPE, 0,
                           $Term, TELNET_IAC, TELNET_SE);
            $t-&gt;put(String =&gt; $telcmd,
                    Telnetmode =&gt; 0);
        }

        1;
    } # end sub subopt_callback</code></pre>

<p>You can also use Net::Telnet to interact with local programs. This example changes a user&#39;s login password. It introduces the <code>spawn()</code> subroutine to start a program and associate a filehandle with its standard I/O. Because the passwd program always prompts for passwords on its controlling terminal, the IO::Pty module is used to create a new pseudo terminal for use by passwd. The Net::Telnet object reads and writes to that pseudo terminal. To use the code below, substitute &quot;changeme&quot; with the actual old and new passwords.</p>

<p>## Main program. { my ($pty, $passwd); my $oldpw = &quot;changeme&quot;; my $newpw = &quot;changeme&quot;;</p>

<pre><code>    ## Start passwd program.
    $pty = spawn(&quot;passwd&quot;);

    ## Create a Net::Telnet object to perform I/O on passwd&#39;s tty.
    use Net::Telnet;
    $passwd = new Net::Telnet (-fhopen =&gt; $pty,
                               -timeout =&gt; 2,
                               -output_record_separator =&gt; &quot;\r&quot;,
                               -telnetmode =&gt; 0,
                               -cmd_remove_mode =&gt; 1);
    $passwd-&gt;errmode(&quot;return&quot;);

    ## Send existing password.
    $passwd-&gt;waitfor(&#39;/password: ?$/i&#39;)
        or die &quot;no old password prompt: &quot;, $passwd-&gt;lastline;
    $passwd-&gt;print($oldpw);

    ## Send new password.
    $passwd-&gt;waitfor(&#39;/new (\w+\s)?password: ?$/i&#39;)
        or die &quot;bad old password: &quot;, $passwd-&gt;lastline;
    $passwd-&gt;print($newpw);

    ## Send new password verification.
    $passwd-&gt;waitfor(&#39;/new (\w+\s)?password: ?$/i&#39;)
        or die &quot;bad new password: &quot;, $passwd-&gt;lastline;
    $passwd-&gt;print($newpw);

    ## Display success or failure.
    $passwd-&gt;waitfor(&#39;/(changed|updated)/&#39;)
        or die &quot;bad new password: &quot;, $passwd-&gt;lastline;
    print $passwd-&gt;lastline;

    $passwd-&gt;close;
    exit;
} # end main program</code></pre>

<p>sub spawn { my (@cmd) = @_; my ($pid, $pty, $tty, $tty_fd);</p>

<pre><code>    ## Create a new pseudo terminal.
    use IO::Pty ();
    $pty = new IO::Pty
        or die $!;

    ## Execute the program in another process.
    unless ($pid = fork) {  # child process
        die &quot;problem spawning program: $!\n&quot; unless defined $pid;

        ## Disassociate process from its controlling terminal.
        use POSIX ();
        POSIX::setsid()
            or die &quot;setsid failed: $!&quot;;

        ## Associate process with a new controlling terminal.
        $pty-&gt;make_slave_controlling_terminal;
        $tty = $pty-&gt;slave;
        $tty_fd = $tty-&gt;fileno;
        close $pty;

        ## Make standard I/O use the new controlling terminal.
        open STDIN, &quot;&lt;&amp;$tty_fd&quot; or die $!;
        open STDOUT, &quot;&gt;&amp;$tty_fd&quot; or die $!;
        open STDERR, &quot;&gt;&amp;STDOUT&quot; or die $!;
        close $tty;

        ## Execute requested program.
        exec @cmd
            or die &quot;problem executing $cmd[0]\n&quot;;
    } # end child process

    $pty;
} # end sub spawn</code></pre>

<p>Here is an example that uses the openssh program to connect to a remote host. It uses the <code>spawn()</code> subroutine, from the password changing example above, to start the ssh program and then read and write to it via a Net::Telnet object. This example turns off ssh host key checking, which reduces your ability to know when someone on the network is impersonating the remote host. To use the code below, substitute &quot;changeme&quot; with the actual host, user, password, and command prompt.</p>

<pre><code>    ## Main program.
    {
        my $host = &quot;changeme&quot;;
        my $user = &quot;changeme&quot;;
        my $passwd = &quot;changeme&quot;;
        my $prompt = &#39;/changeme\$ $/&#39;;
        my ($buf, $match, $pty, $ssh, @lines);

        ## Start ssh program.
        $pty = spawn(&quot;ssh&quot;,
                     &quot;-l&quot;, $user,
                     &quot;-e&quot;, &quot;none&quot;,
                     &quot;-F&quot;, &quot;/dev/null&quot;,
                     &quot;-o&quot;, &quot;PreferredAuthentications=password&quot;,
                     &quot;-o&quot;, &quot;NumberOfPasswordPrompts=1&quot;,
                     &quot;-o&quot;, &quot;StrictHostKeyChecking=no&quot;,
                     &quot;-o&quot;, &quot;UserKnownHostsFile=/dev/null&quot;,
                     $host);

        ## Create a Net::Telnet object to perform I/O on ssh&#39;s tty.
        use Net::Telnet;
        $ssh = new Net::Telnet (-fhopen =&gt; $pty,
                                -prompt =&gt; $prompt,
                                -telnetmode =&gt; 0,
                                -output_record_separator =&gt; &quot;\r&quot;,
                                -cmd_remove_mode =&gt; 1);

        ## Wait for the password prompt and send password.
        $ssh-&gt;waitfor(-match =&gt; &#39;/password: ?$/i&#39;,
                      -errmode =&gt; &quot;return&quot;)
            or die &quot;problem connecting to \&quot;$host\&quot;: &quot;, $ssh-&gt;lastline;
        $ssh-&gt;print($passwd);

        ## Wait for the shell prompt.
        (undef, $match) = $ssh-&gt;waitfor(-match =&gt; $ssh-&gt;prompt,
                                        -match =&gt; &#39;/^Permission denied/m&#39;,
                                        -errmode =&gt; &quot;return&quot;)
            or return $ssh-&gt;error(&quot;login failed: expected shell prompt &quot;,
                                  &quot;doesn&#39;t match actual\n&quot;);
        return $ssh-&gt;error(&quot;login failed: bad login-name or password\n&quot;)
            if $match =~ /^Permission denied/m;

        ## Run commands on remote host.
        print $ssh-&gt;cmd(&quot;hostname&quot;);
        print $ssh-&gt;cmd(&quot;uptime&quot;);

        $ssh-&gt;close;
        exit;
    } # end main program</code></pre>

<p>Some shells have a rather restrictive 255 character line limit. If you run into this problem, here is an example for sending lines longer than 254 as a sequence of shorter lines.</p>

<pre><code>    ## Main program.
    {
        my $host = &quot;changeme&quot;;
        my $user = &quot;changeme&quot;;
        my $passwd = &quot;changeme&quot;;
        my $prompt = &#39;/changeme\$ $/&#39;;
        my $cmd = join(&quot;&quot;, &quot;echo &quot;,
                       &quot;11111111112222222222333333333344444444445555555555&quot;,
                       &quot;66666666667777777777888888888899999999990000000000&quot;,
                       &quot;11111111112222222222333333333344444444445555555555&quot;,
                       &quot;66666666667777777777888888888899999999990000000000&quot;,
                       &quot;11111111112222222222333333333344444444445555555555&quot;,
                       &quot;66666666667777777777888888888899999999990000000000&quot;);

        use Net::Telnet ();
        my $t = new Net::Telnet (-prompt =&gt; $prompt);
        $t-&gt;open($host);
        $t-&gt;login($user, $passwd);

        my @output = cmd_unixlong($t, $cmd);
        print @output;

        exit;
    } # end main program

    sub cmd_unixlong {
        my ($obj, $cmd) = @_;
        my ($line, $pos);
        my $max_tty_line = 254;

        ## Start a Bourne shell.
        $obj-&gt;cmd(-string =&gt; &quot;/usr/bin/env &quot; .
                  &quot;&#39;PS1=&lt;xPROMPTx&gt; &#39; &#39;PS2=&lt;xPROMPTx&gt; &#39; /bin/sh -i&quot;,
                  -prompt =&gt; &#39;/&lt;xPROMPTx&gt; $/&#39;)
            or return;

        ## Break-up the one large command line and send as shorter lines.
        $pos = 0;
        while (1) {
            $line = substr $cmd, $pos, $max_tty_line;
            $pos += length $line;
            last unless $pos &lt; length $cmd;

            ## Send the line with continuation char.
            $obj-&gt;cmd(-string =&gt; &quot;$line\\&quot;,
                      -prompt =&gt; &#39;/&lt;xPROMPTx&gt; $/&#39;)
                or return;
        }

        ## Send the last line and return the output.
        $obj-&gt;cmd(&quot;$line ; exit&quot;);
    } # end sub cmd_unixlong</code></pre>

<h1 id="AUTHOR">AUTHOR</h1>

<p>Jay Rogers &lt;jay@rgrs.com&gt;</p>

<h1 id="CREDITS">CREDITS</h1>

<p>Dave Martin, Dave Cardosi</p>

<h1 id="COPYRIGHT">COPYRIGHT</h1>

<p>Copyright 1997, 2000, 2002, 2013, 2021 by Jay Rogers. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install Net::Telnet, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm Net::Telnet</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install Net::Telnet</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./Net::Telnet.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
